<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<script src="/js/jquery-3.4.1.min.js"></script>
<style>
    td{width: 200px;border: black solid 1px;}
    tr{border-bottom: black solid 1px;}
    table{border: black solid 1px;text-align: center;}
</style>
<body>
<h4>全部简历</h4>
<button id="add" onclick="updateResume('')">增加简历</button>
<table  id="infoTable">
    <tbody>
    <th>姓名</th>
    <th>手机号</th>
    <th>地址</th>
    <th>操作</th>
    </tbody>
</table>


<script>
    function updateResume(obj){
       window.location.href="/resume/editResume?id="+obj;
    }
    function deleteResume(obj){
        $.ajax({
            url: '/resume/deleteResume',
            type: 'POST',
            data: {
                "id":obj
            },
            success: function (data) {
                location.reload();
            }
        });


    }
    $(function () {
        $.ajax({
            url: '/resume/findAll',
            type: 'POST',
            data: '',
            success: function (data) {
                if (data) {
                    var tr="";
                    for (i = 0; i < data.length; i++) {
                        var trInfo = "<tr>";
                        trInfo += "<td>" + data[i].name + "</td>";
                        trInfo += "<td>" + data[i].phone + "</td>";
                        trInfo += "<td>" + data[i].address + "</td>";
                        trInfo += '<td><button onclick="updateResume(' + data[i].id+ ')">修改</button>';
                        trInfo += '<button onclick="deleteResume(' + data[i].id + ')">删除</button></td>';
                        trInfo += "</tr>";
                        tr += trInfo;
                    }
                    $("#infoTable").find("tbody").append(tr);
                } else {
                    alter("加载错误");
                }
            }
        });
    });
</script>

</body>
</html>
